﻿/// <reference path="jquery-1.8.3.js" />
//Z-INDEX最小为1，最大为9999；1-100和9000-9999为应用保留Z-Index；101-8999为应用中生成对象可用层，可建立使用工具8898个

var const_UserCustomLayer = 101; //用户自定义起始层
var isPainting = false; //是否开始绘制图形
var isMouseDown = false;//鼠标是否按下
var canvasWork, contentWork; //工作canvas和内容canvas

//实现铅笔工具需要用到的全局变量（不保证留用，过后舍弃）
var mouseX = new Array();//鼠标X轴值数组
var mouseY = new Array();//鼠标Y轴值数组
var isMouseDrag = new Array();//鼠标当前是否按下BOOL数组
var selectToolTitle = "";//当前选中工具的标题文本

//定义全局常量对象
function GlobalConst() {
    this.ZIndex_DesktopLayer = 1; //桌面层
    this.ZIndex_casPencil = 9000; //画布层
    this.ZIdex_casTemp = 9001; //临时提权层层
    this.ZIndex_ToolBoxLayer = 9100; //工具箱层
    this.ZIndex_ToolListLayer = 9101; //工具列表层
    this.ZIndex_SwitchLayer = 9102; //Switch开关层
    this.KeyPointRadius = 4;//关键点圆半径
    this.IndexKeyPoint = -1;//设置关键点索引值
}

//设置层
function setLayer(strParentElementID, intzindex) {
    $("#" + strParentElementID).css("z-index", intzindex);
}

//计算两点间直线距离
function getDistance(cpMouse, ckpSelect) {
    var xdiff = cpMouse.X - ckpSelect.X;
    var ydiff = cpMouse.Y - ckpSelect.Y;
    return Math.sqrt((xdiff * xdiff + ydiff * ydiff));
}

function addZero(strsource, lenght) {
    if (strsource.length >= lenght)
        return strsource;
    else
        return addZero("0" + strsource, lenght);

}